package com.atguigu.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Aspect
@Component
@Order(1)
public class AroundInfo {

    @Pointcut(value = "execution(public * com.atguigu..*.*(..))")
    public void pointCut(){}

    @Around("pointCut()")
    public  Object around(ProceedingJoinPoint point){
        Object proceed =null;
        try {
            before();
            proceed = point.proceed();
            afterReturning();
        } catch (Throwable e) {
            afterThrowing(e);
        }
        after();
        return proceed;
    }

    public void before(){
        System.out.println("before..............");
    }
    public void afterReturning(){
        System.out.println("afterReturning..............");
    }
    public void afterThrowing(Throwable e){
        System.out.println("afterTrowing.............."+e.getCause());
    }
    public void after(){
        System.out.println("after..............");
    }
}
